$(document).ready(function () {
    cztdysxx.onload();
})

var cztdysxx = (function () {

    var init = function () {
    }

    return {
        onload : function () {
            init();
//          cztdysxx.windowResize();
            cztdysxx.tableData();
            cztdysxx.bgClick();
            cztdysxx.bgTableData();
            
        },
        /*页面计算*/
//      windowResize:function(){
//      	var content_xxcj_h=$(document).height()-20;
//			$(".wxl_cztdysxx").css("height",content_xxcj_h+"px");
//      },
         /*查看土地等级弹框*/
        cktddj:function(){
        	layui.use('layer', function(){
				var layer = layui.layer;
				layer.confirm('土地等级信息', {
				btn: ['确定', '取消'] //按钮
				}, function() {
					window.location.href='cztdysxx.html';
					
				}, function() {
					layer.close()
				})
			}); 
		},
          /*变更弹框信息*/
        bgInfo:function(){
        	layui.use('layer', function() {
					var layer = layui.layer;
					layer.open({
						type: 1,
						id:'layer_open',
						skin: 'layui-layer-demo', //样式类名
						closeBtn: 1, //不显示关闭按钮
						anim: 2,
						title: '编辑应税信息',
						area: ['98%', '500px'],
						shadeClose: true, //开启遮罩关闭
						content: $('.wxl_cztdysxx_tk_box').html()
					});
			});
        },
       /*日期显示*/
      dateShow:function(){
      	layui.use('laydate', function(){
			  var laydate = layui.laydate;
			  laydate.render({
				    elem: '#layer_open #wxl_date1'
				    ,theme: 'molv'
			 });
			  laydate.render({
			    elem: '#layer_open #wxl_date2'
			    ,theme: 'molv'
			  });

		})
      },
      /*保存关闭弹框*/
     saveForm:function(){
     	layer.closeAll()
     },
     /*table表格数据*/
    tableData:function(){
    	var data = [{
 				"area": "455平方米",
 				"landGrade": "3级",
 				"taxStandard": "税申报",
 				"dateStart": "2018-4-13",
 				"dateEnd": "2018-05-01",
 				"reduceNum": 5666,
 				"operation": null
 			},
 			{
 				"area": "455平方米",
 				"landGrade": "1级",
 				"taxStandard": "税申报",
 				"dateStart": "2018-4-12",
 				"dateEnd": "2018-05-01",
 				"reduceNum": 5666,
 				"operation": null
 			}
 		];
 		$('#wxlCztdysxx').DataTable({
 			"data": data,
 			"columnDefs": [{
 					"targets": -1,
 					"data": null,
 					"render": function(data, type, full, meta) {
 						return '<span class="btn wxl_bg_yel wxl_btn_bg">变更</span>'
 					}
 				},
 				{
 					'targets': 0,
 					'className': 'dt-body-center',
 					'render': function(data, type, row) {
 						return '<input class="checkchild" type="checkbox"/>';
 					}
 				}
 			],
 			"columns": [
 			    {
 					"data": "btn"
 				},
 			    {
 					"data": "area"
 				},
 				{
 					"data": "landGrade"
 				},
 				{
 					"data": "taxStandard"
 				},
 				{
 					"data": "dateStart"
 				},
 				{
 					"data": "dateEnd"
 				},
 				{
 					"data": "reduceNum"
 				},
 				{
 					"data": "operation"
 				}
 			],
// 	        "paging": false,
// 			"info": false,
// 			"lengthChange": false,
// 			"searching": false
 		})
    },
    /*点击变更按钮事件*/
     bgClick:function(){
     	$(document).on("click",".wxl_btn_bg", function(){
			cztdysxx.bgInfo();
			cztdysxx.dateShow();
			cztdysxx.tdDeleted();
		});
     },
     /*变更弹框表格数据*/
    bgTableData:function(){
    	var data = [{
   				"number": "01",
   				"reduceCode": "3级",
   				"reduceArea": "98平方米",
   				"reduceMoney": "888888",
   				"dateStart": "2018-05-01",
   				"dateEnd": "2018-05-02",
   				"operation": null
   			},
   			{
   				"number": "02",
   				"reduceCode": "2级",
   				"reduceArea": "50平方米",
   				"reduceMoney": "888888",
   				"dateStart": "2018-05-01",
   				"dateEnd": "2018-05-04",
   				"operation": null
   			}
   		];
   		$('#wxlcztdysxxTk').DataTable({
   			"data": data,
   			"columnDefs": [{
   					"targets": -1,
   					"data": null,
   					"render": function(data, type, full, meta) {
   						return '<span class="btn wxl_bg_lan1 wxl_btn_add">增加</span><span class="btn wxl_bg_red wxl_btn_deleted">删除</span>'
   					}
   				},
   				{
   					'targets': 0,
   					'className': 'dt-body-center',
   					'render': function(data, type, row) {
   						return '<input class="checkchild" type="checkbox"/>';
   					}
   				}
   			],
   			"columns": [
   			    {
   					"data": "btn"
   				},
   			    {
   					"data": "number"
   				},
   				{
   					"data": "reduceCode"
   				},
   				{
   					"data": "reduceArea"
   				},
   				{
   					"data": "reduceMoney"
   				},
   				{
   					"data": "dateStart"
   				},
   				{
   					"data": "dateEnd"
   				},
   				{
   					"data": "operation"
   				}
   			],
// 			"paging": false,
   			"info": false,
   			"lengthChange": false,
   			"searching": false
   		});
    },
     /*变更弹框表格行删除*/
    tdDeleted:function(){
    	var table = $('#wxlcztdysxxTk').DataTable();
		$('#wxlcztdysxxTk tbody').on( 'click', 'span.wxl_btn_deleted', function () {
			alert("1111");
		    table.row( $(this).parents('tr') ).remove() .draw(false);
		} );
    },
    }
})();
